<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>添加供应商 - ${provider.name }</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<link rel="stylesheet" href="admin/css/common.css" type="text/css" />
	<link rel="stylesheet" href="admin/css/provider.css" type="text/css" />
	<script type="text/javascript" src="js/jquery-1.7.1.js"></script>
	
	<script type="text/javascript">
	
		function check(){
			/*//判断是否有数据为空未填写完整
			var inputs = $('.tiny-input').size();
			for(j=0;j<inputs;j++){
				var tmp = $('.tiny-input').get(j);
				if(tmp.value == ''){
					alert('请填充空的数据!');
					return false;
				}
			}
			//取得最后选择好的石块
			var ids = $('.hidden').size();
			var s = "";
			for(i=0;i<ids;i++){
				var tmp = $('.hidden').get(i);
				s += tmp.value+";";
			}
			s = s.substr(0,s.length-1);
			$('#selectedStones').val(s);*/
			return true;
		//	alert($('#selectedStones').val());
		}

		function checkMinPrice(id1,id2){
			//id1 +='#'+id1;
			//id2 +='#'+id2;
			var num1 = $(id1).val();
			var num2 = $(id2).val();
			if(num1 == "" ||num2 == "")
				return;	
			num1 = parseFloat(num1);
			num2 = parseFloat(num2);
			if($(id1).val() == ''){
				alert('请输入价格下限');
			}else if($(id2).val() != '' 
				&& num1 > num2 ){
				alert('价格下限必须不大于上限，请重新输入!');
			}
		}

		function checkMaxPrice(id1,id2){
			var num1 = $(id1).val();
			var num2 = $(id2).val();
			if(num1 == "" ||num2 == "")
				return;	
			num1 = parseFloat(num1);
			num2 = parseFloat(num2);
			if($(id2).val() == '' || num2 < num1){
				alert('价格上限必须不小于下限!'); 
			} 
		}
	</script>
  </head>
  <body>
  	<div id="provider_zone">
  	  <form action="provider/saveProviderStones.action" name="providerForm" method="post" onsubmit="return check();">
	  	 <table width="99%" border="0" align="center"  cellpadding="3" cellspacing="1" class="table_style">
		    <tr class="head">
		    	<th width="25%" style="min-width: 150px">石材名称</th>
		    	<th width="10%">石材质</th>
		    	<th width="10%">石材量</th>
		    	<th width="6%">荒料价格下限</th>
		    	<th width="6%">荒料价格上限</th>
		    	<th width="6%">大板价格下限</th>
		    	<th width="6%">大板价格上限</th>
		    	<th width="10%">排序权值</th>
		    	<th width="15%">操作</th>
		    </tr>
			<c:forEach items="${stonesList}" var="item">
		    	<tr id="tr${item.id }">
			    	<td align="center">
			    		<a href="stone/toStoneCompany.action?stoneId=${item.id }" title="点击查看此石材" target="_blank"> ${item.chineseName } </a>
			    		<input type="hidden" class="hidden" name="hidden" value="${item.id }">
			    	</td>
			    	<td align="center">
			    		<select name="quality${item.id }" id="quality${item.id }" title="供应商此石材的质量" >
			    			<option value="A" selected="selected">&nbsp;&nbsp;A</option>
			    			<option value="B">&nbsp;&nbsp;B</option>
			    			<option value="C">&nbsp;&nbsp;C</option>
			    			<option value="D">&nbsp;&nbsp;D</option>
			    		</select>
			    	</td>
			    	<td align="center">
			    		<select name="quantity${item.id }" id="quantity${item.id }" title="供应商此石材的数量">
			    			<option value="大量" selected="selected">&nbsp;&nbsp;大&nbsp;量</option>
			    			<option value="中量">&nbsp;&nbsp;中&nbsp;量</option>
			    			<option value="少量">&nbsp;&nbsp;少&nbsp;量</option>
			    			<option value="其他">&nbsp;&nbsp;其&nbsp;他</option>
			    		</select>
			    	</td>
			    	<td align="center"><input class="tiny-input" name="rawMinprice${item.id }" id="rawMinprice${item.id }" maxlength="9" value="" onblur="javascript:value=parseFloat(value);value=value.replace(/[^\d\.]/g,''); checkMinPrice(rawMinprice${item.id },rawMaxprice${item.id })" onkeyup="value=value.replace(/[^\d\.]/g,'');" title="荒料价格下限，只能输入数字和小数点">	</td>
			    	<td align="center"><input class="tiny-input" name="rawMaxprice${item.id }" id="rawMaxprice${item.id }" maxlength="9" value="" onblur="javascript:value=parseFloat(value);value=value.replace(/[^\d\.]/g,''); checkMaxPrice(rawMinprice${item.id },rawMaxprice${item.id })" onkeyup="value=value.replace(/[^\d\.]/g,'')"  title="荒料价格上限，必须大于下限" >	</td>
			    	<td align="center"><input class="tiny-input" name="slabMinprice${item.id }" id="slabMinprice${item.id }" maxlength="9" value="" onblur="javascript:value=parseFloat(value);value=value.replace(/[^\d\.]/g,''); checkMinPrice(slabMinprice${item.id },slabMaxprice${item.id })" onkeyup="value=value.replace(/[^\d\.]/g,'');" title="大板价格下限，只能输入数字和小数点">	</td>
			    	<td align="center"><input class="tiny-input" name="slabMaxprice${item.id }" id="slabMaxprice${item.id }" maxlength="9" value="" onblur="javascript:value=parseFloat(value);value=value.replace(/[^\d\.]/g,''); checkMaxPrice(slabMinprice${item.id },slabMaxprice${item.id })" onkeyup="value=value.replace(/[^\d\.]/g,'')"  title="大板价格上限，必须大于下限" >	</td>
			    	<td align="center"><input class="tiny-input" name="weight${item.id }" id="weight${item.id }" maxlength="3" value="0" onblur="javascript: value=parseInt(value,10); if(this.value == '') {alert('请输入权值');}" onkeyup="value=value.replace(/[^\d]/g,'')"  title="数字越小排序越前">	</td>
			    	<td align="center">
			    		<a href="javascript:$('#tr${item.id }').remove();" onclick="return confirm('确定移除此石材出其销售范围？');"> 移除 </a>
			    	</td>
		  		</tr>
		    </c:forEach>
		    <tr>
		    	<td  colspan="10" class="left_title_2">
		    		<input type="hidden" id="selectedStones" name="selectedStones" value="${selectedStones}" />
		    		<input type="hidden" value="${providerId}" name="providerId" />
					<input type="submit" class="input-submit" value="保存完成">
				</td>
		    </tr>
		  </table>
	  </form>
	</div>
  </body>
 <!--  <script type="text/javascript">
  	SortD(document.getElementById('allStones'));
  	SortD(document.getElementById('selStones'));
  </script> -->
</html>
